package cn.zsc.netdisk.response;

import java.io.Serializable;

/**
 * @author ccying
 * @date 2021/2/4
 */
public class Result implements Serializable {
    private int code;
    private String message;
    private Object data;

    private Result() {
    }

    private Result(Code code) {
        this.code = code.getCode();
        this.message = code.getMessage();
    }

    private Result(Code code, Object data) {
        this.code = code.getCode();
        this.message = code.getMessage();
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public Object getData() {
        return data;
    }

    public static Result success() {
        return success("");
    }

    public static Result success(Object data) {
        Result result = new Result(Code.SUCCESS, data);
        return result;
    }

    public static Result success(Object[] data) {
        Result result = new Result(Code.SUCCESS, data);
        return result;
    }
    
    public static Result fail(Code code) {
        return fail(code, "");
    }

    public static Result fail(Code code, Object data) {
        Result result = new Result(code, data);
        return result;
    }
}